package com.example.tijian_doctor_backend.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.tijian_doctor_backend.dto.CiReportDTO;
import com.example.tijian_doctor_backend.mapper.CiReportMapper;
import com.example.tijian_doctor_backend.mapper.CidetailedreportMapper;
import com.example.tijian_doctor_backend.mapper.OrdersMapper;
import com.example.tijian_doctor_backend.pojo.Cidetailedreport;
import com.example.tijian_doctor_backend.pojo.Cireport;
import com.example.tijian_doctor_backend.pojo.Orders;
import com.example.tijian_doctor_backend.service.CiReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: bong~
 * @description: TODO
 * @date: 2024/6/23 17:25
 * @version: 1.0
 */

@Service
public class CiReportServiceImpl implements CiReportService {


//    @Autowired
//    private OrdersMapper ordersMapper;

    @Autowired
    private CiReportMapper ciReportMapper;

    @Autowired
    private CidetailedreportMapper cidetailedreportMapper;


    @Override
    public List<CiReportDTO> listCiReport(Integer orderId) {

        System.out.println("========================================================");

        QueryWrapper<Cireport> queryWrapper=new QueryWrapper<Cireport>()
                .eq("orderId",orderId);

        List<Cireport> cireportList=ciReportMapper.selectList(queryWrapper);




        List<CiReportDTO> ans=new ArrayList<>();

        System.out.println("========================================================");
        for(Cireport cur:cireportList){



            System.out.println(cur.toString());

            CiReportDTO ciReportDTO=new CiReportDTO();
            ciReportDTO.setCiId(cur.getCiId());
            ciReportDTO.setCiName(cur.getCiName());

            Integer ciId=cur.getCiId();

            QueryWrapper<Cidetailedreport> queryWrapper1=new QueryWrapper<Cidetailedreport>()
                    .eq("ciId",ciId)
                    .eq("orderId",orderId);

            List<Cidetailedreport> list=cidetailedreportMapper.selectList(queryWrapper1);

            for(Cidetailedreport tmp:list){
                System.out.println(tmp);
            }

            ciReportDTO.setCidrList(list);
            ans.add(ciReportDTO);

        }
        return ans;



    }
}
